<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MemberCard extends Model
{
    CONST TYPE_DAYS = 1; // 会员卡类型：计时卡
    CONST TYPE_TIMES = 2; // 会员卡类型：计次卡

    protected $fillable = [
        'tenant_id',
        'type',
        'name',
        'price',
        'market_price',
        'days',
        'count',
        'cover_url',
        'remark',
        'sort',
    ];

    public function tenant()
    {
        return $this->belongsTo(Tenant::class);
    }

    /**
     * 生成订单号
     * @return string
     */
    public static function generateOrderNo($prefix = '')
    {
        return $prefix . date('YmdHis') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
    }
}
